package br.net.woodstock.tickettoride.web.jsf.security.common;

import javax.servlet.http.HttpSession;

import br.net.woodstock.rockframework.web.faces.utils.FacesUtils;
import br.net.woodstock.tickettoride.orm.User;
import br.net.woodstock.tickettoride.web.SecurityUtils;

public abstract class JSFSecurityUtils {

	private JSFSecurityUtils() {
		//
	}

	public static User getSessionUser() {
		HttpSession session = FacesUtils.getSession();
		return SecurityUtils.getSessionUser(session);
	}

	public static void setSessionUser(final User user) {
		HttpSession session = FacesUtils.getSession();
		SecurityUtils.setSessionUser(session, user);
	}

	public static void invalidateSession() {
		HttpSession session = FacesUtils.getSession();
		SecurityUtils.invalidateSession(session);
	}

	public static boolean isLoggedIn() {
		HttpSession session = FacesUtils.getSession();
		return SecurityUtils.isLoggedIn(session);
	}

	public static boolean isUserInRole(final String role) {
		HttpSession session = FacesUtils.getSession();
		return SecurityUtils.isUserInRole(session, role);
	}

}
